﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace Console
{
    public partial class Form2 : Form
    {
        public string _download_url { get; set; }
        public string _post_url { get; set; }
        public string _test_url { get; set; }
        public bool admin;
        public Form2(string _download_url, string _post_url, string _test_url, string header, bool admin)
        {
            InitializeComponent();
            this._download_url = _download_url;
            this._post_url = _post_url;
            this._test_url = _test_url;
            textBox_image.Text = _download_url;
            textBox_control.Text = _post_url;
            textBox_test.Text = _test_url;
            this.admin = admin;
            if (!admin)
            {
                textBox_control.Text = "";
                textBox_control.Enabled = false;
                button_control.Enabled = false;

                textBox_test.Text = "";
                textBox_test.Enabled = false;
                button_test.Enabled = false;

                button_sp.Enabled = false;
            }
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            // TextBox居中
            int textBox_left = (ClientSize.Width - textBox_test.Width) / 2;
            textBox_test.Left = textBox_left;
            textBox_image.Left = textBox_left;
            textBox_control.Left = textBox_left;

            // 计算Label和TextBox的中心高度差
            int delta1 = (label_test.Height - textBox_test.Height) / 2;
            textBox_test.Top = label_test.Top + delta1;
            textBox_image.Top = label_image.Top + delta1;
            textBox_control.Top = label_control.Top + delta1;

            // Label水平位置
            label_test.Left = textBox_test.Left - label_test.Width;
            label_image.Left = textBox_image.Left - label_image.Width;
            label_control.Left = textBox_control.Left - label_control.Width;

            //计算Button和TextBox的中心高度差
            int delta2 = (textBox_test.Height - button_test.Height) / 2;
            button_test.Top = textBox_test.Top + delta2;
            button_image.Top = textBox_image.Top + delta2;
            button_control.Top = textBox_control.Top + delta2;

            // Button水平位置
            button_test.Left = textBox_test.Right;
            button_image.Left = textBox_image.Right;
            button_control.Left = textBox_control.Right;

        }

        private void button_test_Click(object sender, EventArgs e)
        {
            _test_url = textBox_test.Text;
        }

        private void button_image_Click(object sender, EventArgs e)
        {
            _download_url = textBox_image.Text;

        }

        private void button_control_Click(object sender, EventArgs e)
        {
            _post_url = textBox_control.Text;
        }

        private void button_sp_Click(object sender, EventArgs e)
        {
            Form3 form3 = new Form3();
            form3.ShowDialog();
        }

    }
}
